#region "ResourceManagerWrapper"

/*
 * ####     Developer Name : Wang Yucai
 * 
 * ####     Development Tool : Microsoft VisualStudio 2010 Ultimate Edition
 * 
 * ####     Create Time : 2014/7/8 10:26:36
 * 
 * ####     Namespace : Masterduner.SourceStudio.Practices.DevelopmentLibrary.Resources
 * 
 * ####     Type Name : ResourceManagerWrapper
 * 
 * ####     Full Name : Masterduner.SourceStudio.Practices.DevelopmentLibrary.Resources.ResourceManagerWrapper
 * 
 * ####     Machine Name : GLCHQWYCWINW7
 * 
 * ####     UserName : GUOCOLAND/wangyucai
 * 
 * ####     CLR Version : 4.0.30319.18408
 * 
 * ####     Target Framework Version : 4.0
 */

#endregion

using System;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Resources;
using Masterduner.SourceStudio.Practices.DevelopmentLibrary.Globalization;

namespace Masterduner.SourceStudio.Practices.DevelopmentLibrary.Resources
{
    /// <summary>
    /// <para>Masterduner.SourceStudio.Practices.DevelopmentLibrary.Resources.ResourceManagerWrapper</para>
    /// <para>
    /// 提供了访问资源的方法。
    /// </para>
    /// </summary>
    /// <remarks>
    /// <para>Target Framework Version : 4.0</para>
    /// <para>此类不可继承。</para>
    /// </remarks>
    public sealed class ResourceManagerWrapper : ResourceManager
    {
        #region Constructor

        /// <summary>
        /// <para>构造函数：</para>
        /// <para>初始化一个<see cref="ResourceManagerWrapper" />对象实例。</para>
        /// </summary>
        /// <param name="includeResourceAssembly">包含资源的<see cref="Assembly"/>对象实例。</param>
        /// <param name="baseName">资源的基础名称。</param>
        public ResourceManagerWrapper(Assembly includeResourceAssembly, string baseName)
            : base(baseName, includeResourceAssembly)
        {
        }

        #endregion

        #region GetObject
        /// <summary>
        /// 获取名称为<paramref name="name"/>的资源对象。
        /// </summary>
        /// <param name="name">资源名称。</param>
        /// <param name="culture"><see cref="CultureInfo"/>对象实例。</param>
        /// <returns><see cref="Object"/>对象实例。</returns>
        public override object GetObject(string name, CultureInfo culture)
        {
            try
            {
                return base.GetObject(name, culture);
            }
            catch (Exception ex)
            {
                throw new ResourcesExceptionWrapper(base.MainAssembly, base.BaseName, name, ex);
            }
        }

        /// <summary>
        /// 获取名称为<paramref name="name"/>的资源对象。
        /// </summary>
        /// <param name="name">资源名称。</param>
        /// <returns><see cref="Object"/>对象实例。</returns>
        public override object GetObject(string name)
        {
            return this.GetObject(name, CultureExpando.CreateSpecialCulture("zh-CN"));
        }
        #endregion

        #region GetString
        /// <summary>
        /// 获取资源名称为<paramref name="name"/>的资源字符串。
        /// </summary>
        /// <param name="name">资源名称。</param>
        /// <param name="culture"><see cref="CultureInfo"/>对象实例。</param>
        /// <returns><see cref="String"/>。</returns>
        public override string GetString(string name, CultureInfo culture)
        {
            try
            {
                return base.GetString(name, culture);
            }
            catch (Exception ex)
            {
                throw new ResourcesExceptionWrapper(base.MainAssembly, base.BaseName, name, ex);
            }
        }

        /// <summary>
        /// 获取资源名称为<paramref name="name"/>的资源字符串。
        /// </summary>
        /// <param name="name">资源名称。</param>
        /// <returns><see cref="String"/>。</returns>
        public override string GetString(string name)
        {
            return this.GetString(name, CultureExpando.CreateSpecialCulture("zh-CN"));
        }
        #endregion

        #region GetStream
        /// <summary>
        /// 获取资源名称为<paramref name="name"/>的资源流。
        /// </summary>
        /// <param name="name">资源名称。</param>
        /// <param name="culture"><see cref="CultureInfo"/>对象实例。</param>
        /// <returns><see cref="Stream"/>对象实例。</returns>
        public new Stream GetStream(string name, CultureInfo culture)
        {
            try
            {
                return base.GetStream(name, culture);
            }
            catch (Exception ex)
            {
                throw new ResourcesExceptionWrapper(base.MainAssembly, base.BaseName, name, ex);
            }
        }

        /// <summary>
        /// 获取资源名称为<paramref name="name"/>的资源流。
        /// </summary>
        /// <param name="name">资源名称。</param>
        /// <returns><see cref="Stream"/>对象实例。</returns>
        public new Stream GetStream(string name)
        {
            return this.GetStream(name, CultureExpando.CreateSpecialCulture("zh-CN"));
        }
        #endregion
    }
}

#region README

/*
 * ####     ©2014 Wang Yucai
 * 
 * ####     Contact me
 *                  
 *                  E-mail : Masterduner@Yeah.net
 *                  Mobile : 13621384677
 *                  QQ : 180261899
 */

#endregion